import {Component, EventEmitter, OnInit, Output} from '@angular/core';
import {FormControl} from '@angular/forms';
import 'rxjs/add/operator/debounceTime';

@Component({
  selector: 'app-search',
  templateUrl: './search.component.html',
  styleUrls: ['./search.component.css']
})
export class SearchComponent implements OnInit {
  searchTitle: FormControl = new FormControl();
  @Output()
  search: EventEmitter<string> = new EventEmitter<string>();

  constructor() {
    this.searchTitle.valueChanges.debounceTime(350).subscribe(data => {
      this.search.emit(<string>data);
    });
  }

  ngOnInit() {

  }
}
